<?php

/**
 * @package EDO
 * @subpackage Collections
 *
 */
class Lead_EDO_Collection_Indexed extends Lead_EDO_Collection_Base implements ArrayAccess
{

	function key() {
		return $this->_items[$itemid];
	}
	
	function current() {
		if($this->valid())
			return $this->getItem($this->_items[$this->_currIndex]);
		return false;
	}
	
	function next() {
		$this->_currIndex++;
	}
	
	
	public function addItem($res)
	{
		array_push($this->_items, $res);
		$this->_length++;	
	}
	
	
	public function &getItem($itemid)
	{
		 $obj = $this->getHandler()->get($this->_object);
	    #$obj->fetch($this->_items[$itemid]);
		
		$obj->fetch($itemid);
		return $obj;

	}
	
	
	public function getKeys()
	{
		return array_values($this->_items);
	}
	
	
	public function offsetExists ($offset)
	{
		return in_array($offset,$this->_items);	
	}
 	public function offsetGet ($offset)
 	{
 		return $this->getItem($offset);
 	}
 	public function offsetSet ($offset, $value)
 	{
 		return true;
 	}
 	public function offsetUnset ($offset)
 	{
		$offs = array_search($offset,$this->_items);
 		unset($this->_items[$offs]);
 		$this->_length--;
 		return true;		
 	}
	
	

}
